package com.runda.partypolicy.app.page.fragment.office;


import android.os.Bundle;


import com.runda.partypolicy.R;
import com.runda.partypolicy.app.base.BaseFragment;
import com.runda.partypolicy.app.page.adapter.Adapter_Item;
import com.runda.partypolicy.app.page.viewmodel.ViewModel_Office_Second;
import com.runda.partypolicy.app.repository.bean.ItemData;


import java.util.ArrayList;
import java.util.List;

import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;

/**
 * author:  RD_YH
 * date:    2019/4/18
 * version: v1.0
 * description:
 */
public class Fragment_Office_Second extends BaseFragment<ViewModel_Office_Second> {

    @BindView(R.id.rv_office_second)
    RecyclerView rvOfficeSecond;

    List<ItemData> dataList = new ArrayList<>();
    private String[] texts = new String[]{"政务热线", "政务审批", "经济指标"};
    private int[] iamges = new int[]{R.drawable.icon_office_zwrx, R.drawable.icon_office_zwsp, R.drawable.icon_office_jjzb};

    private Adapter_Item adapter;

    public static Fragment_Office_Second newInstance() {

        Bundle args = new Bundle();

        Fragment_Office_Second fragment = new Fragment_Office_Second();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public int getLayout() {
        return R.layout.fragment_office_second;
    }

    @Override
    public ViewModel_Office_Second initViewModel() {
        return ViewModelProviders.of(this, getViewModelFactory()).get(ViewModel_Office_Second.class);
    }

    @Override
    public void initEvents() {

    }

    @Override
    public void start() {
        initData();
    }

    @Override
    public void initNotSignEvent() {

    }

    @Override
    public void initNoNetworkEvent() {

    }

    @Override
    public void initShowMessageEvent() {

    }

    @Override
    public void initTokenOverTimeEvent() {

    }

    @Override
    public void initShowOrDismissWaitingEvent() {

    }

    @Override
    public void initStateLayoutEvent() {

    }

    private void initData() {

        if (dataList.size() > 0) {
            dataList.clear();
        }
        for (int i = 0; i < iamges.length; i++) {
            ItemData itemData = new ItemData();
            itemData.setImage(iamges[i]);
            itemData.setText(texts[i]);
            dataList.add(itemData);
        }

        GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), 2);

        adapter = new Adapter_Item(R.layout.item_department, dataList);
//        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
//            @Override
//            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
//                String text = texts[position];
//
//                if ("通知公告".equals(text) || "政务热线".equals(text)) {
//
//                } else if ("公文批阅".equals(text)) {
//                    IntentUtil.startActivity(getActivity(), Activity_OfficialReview.class);
//                } else {
//                    IntentUtil.startActivityWithOperation(getActivity(), Activity_RequestReport.class, new IntentUtil.IntentOperation() {
//                        @Override
//                        public void operate(Intent intent) {
//                            intent.putExtra("title", text);
//                        }
//                    });
//                }
//
//
//            }
//        });
        rvOfficeSecond.setLayoutManager(layoutManager);
        rvOfficeSecond.setAdapter(adapter);
    }

}
